<?php
/*
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
class statement
{
	public static $ROOT = 0;
	
	//expressions
	public static $STATEMENT = 11;
	public static $EXPR = 12;
	
	//constants
	public static $VARIABLE = 15;
	public static $CONSTANT = 16;
	public static $NUMBER = 17;
	public static $DATA_VAR = 18;
	public static $SYS_VAR = 19;
	public static $NULL = 20;
	
	public static $IF = 20;
	
	public static $EQUAL = 30;
	
	public static $EQUILITY = 42;
	public static $LESS_THAN = 43;
	public static $GREATER_THAN = 44;
	public static $OR = 45;
	public static $AND = 46;
	public static $LESS_THAN_EQUAL = 47;
	public static $GREATER_THAN_EQUAL = 48;
	public static $NOT_EQUILITY = 49;
	public static $NOT_EXPR = 50;
	
	public static $DOT = 51;
	
	public static $ADD = 59;
	public static $SUB = 60;
	public static $MUL = 61;
	public static $DIV = 62;
	
	public static $ADD_EQUAL = 63;
	public static $SUB_EQUAL = 64;
	public static $MUL_EQUAL = 65;
	public static $DIV_EQUAL = 66;
	
	public static $ADD_ADD = 67; //++ operator
	public static $SUB_SUB = 68; //-- operator
	
	// database
	public static $SELECT = 70;
	public static $FROM = 71;
	public static $WHERE = 72;
	public static $FROM_DECL = 73;
	public static $DECL = 74;
	public static $DELETE = 75;
	public static $CAST = 76;
	public static $ASSIGNER = 77;
	
	// parse function..
	public static $FUNCTION = 80;
	public static $PARAMS = 81;
	
	//for just a token
	public static $TOKEN = 100;
	
	public $type;
	public $start;
	public $end;
	public $childs;
	
	public function __construct($type, $start, $end) 
	{
		$this->start = $start;
		$this->end = $end;
		
		$this->type = $type;
		$this->childs = array();
	}
	
	public function add_child_to_end( $child)
	{
		$length = $this->childs.length;
		$this->childs[$length] = $child;
	}
	
	public function set_end($end)
	{
		$this->end = $end;
	}
	
	public function add_child($key, $child)
	{
		$this->childs[$key] = $child;
	}
	
	public function get_child($key)
	{
		return $this->childs[$key];
	}
	
	public function get_childs()
	{
		return $this->childs;
	}
	
	public function print_this()
	{
		echo "TYPE:".$this->type."\n";
		echo "START:".$this->start."\n";
		echo "END:".$this->end."\n";
		echo "childs:\n";
		print_r($this->childs);
		echo "\n";
	}
	
}
?>